package com.yunhai.device.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yunhai.common.dto.PaginationVo;
import com.yunhai.common.dto.Ret;
import com.yunhai.device.service.ProductGuideService;
import com.yunhai.model.entity.dms.DmsProductGuideEntity;
import com.yunhai.model.vo.dms.DmsProductGuideQuery;
import com.yunhai.model.vo.dms.DmsProductGuideVo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/productGuide")
public class ProductGuideController {

	@Resource
	private ProductGuideService productGuideService;


	/**
	 * 获取 ProductGuide 分页列表
	 */
	@GetMapping("/pagination")
	public Ret getProductGuidePagination(PaginationVo paginationVo, DmsProductGuideQuery dmsProductGuideQuery ) throws Exception {
		IPage page = productGuideService.getProductGuidePagination(paginationVo, dmsProductGuideQuery );
		return Ret.toPage(page);
	}


	/**
	 * 获取 ProductGuide 所有数据
	 */
	@GetMapping("/allList")
	public Ret getProductGuideAllList( DmsProductGuideQuery dmsProductGuideQuery ) throws Exception {
		List<DmsProductGuideEntity> list = productGuideService.getProductGuideAllList( dmsProductGuideQuery );
		return Ret.ok(list);
	}


	/**
	 * 获取 ProductGuide 详情
	 */
	@GetMapping("/{id}")
	public Ret getProductGuideDetailById(@PathVariable Long id) throws Exception {

	    DmsProductGuideEntity dmsProductGuideEntity = productGuideService.getProductGuideDetail(id);
		return Ret.ok(dmsProductGuideEntity);
	}


	/**
	 * 新增 ProductGuide
	 * */
	@PostMapping("")
	public Ret addProductGuide(@RequestBody DmsProductGuideVo dmsProductGuideVo) throws Exception {

		productGuideService.addProductGuide(dmsProductGuideVo);
		return Ret.ok();
	}


	/**
	 * 更新 ProductGuide
	 * */
	@PutMapping("")
	public Ret updateProductGuide(@RequestBody DmsProductGuideVo dmsProductGuideVo) throws Exception {

		productGuideService.updateProductGuide(dmsProductGuideVo);
		return Ret.ok();
	}


	/**
	 * 删除 ProductGuide
	 * */
	@PostMapping("/batchRemove")
	public Ret batchRemoveProductGuide( @RequestBody List<Long> ids ) throws Exception {

	    productGuideService.batchRemoveProductGuide(ids);
		return Ret.ok();
	}
}
